﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UTSDAL.LINQSQL.Model;

namespace UTSDAL.LINQSQL.Utils
{
    /// <summary>
    /// Utility class for DAOs
    /// </summary>
    public class DAOUtils
    {
        /// <summary>
        /// checks whether a room contains all facilities required by a module
        /// </summary>
        /// <param name="roomFacilities"></param>
        /// <param name="moduleEventFacilities"></param>
        /// <returns></returns>
        public static Boolean doesRoomFacilitiesContainModuleEventFacilities(List<RoomFacility> roomFacilities, List<ModuleEventFacility> moduleEventFacilities)
        {
            Boolean contains = true;

            foreach (ModuleEventFacility facility in moduleEventFacilities)
            {
                contains = doesRoomFacilitiesContainModuleEventFacility(roomFacilities, facility);

                if (!contains)
                {
                    break;
                }
            }

            return contains;

        }

        /// <summary>
        /// checks whether a room contains one facility required by a module
        /// </summary>
        /// <param name="roomFacilities"></param>
        /// <param name="moduleEventFacility"></param>
        /// <returns></returns>
        public static Boolean doesRoomFacilitiesContainModuleEventFacility(List<RoomFacility> roomFacilities, ModuleEventFacility moduleEventFacility)
        {
            Boolean contains = true;


            foreach (RoomFacility roomFacility in roomFacilities)
            {
                if(!roomFacility.Facility.FacilityId.Equals(moduleEventFacility.Facility.FacilityId))
                {
                    contains = false;
                    break;
                }
            }


            return contains;
        }
    }
}
